﻿@{
    ViewData["Title"] = "Home Page";
}

<table class="table">
    <thead>
        <tr><th>标题</th><th>访问次数</th><th>作者</th></tr>
    </thead>
    <tbody id="TBody">
    </tbody>
</table>
@section scripts
{
    <script>
        $(function () {
            FillData(0);
        });
        function FillData(pageNo) {
            ShowLoading();
            CallAjax("@Url.Action("GetList")", { pageNo: pageNo }, function (ret) {
                var strHtml = "";
                $.each(ret.message, function (n, v) {
                    strHtml+=`<tr><td><a href='/home/detail/${v.ID}'>${v.Title}</a></td><td>${v.VisitCount}</td><td>${v.UserName}</td></tr>`
                });

                if (ret.hasMore) {
                    pageNo++;
                    strHtml += `<tr id="TRMore"><td colspan="3"><a href='javascript:;' onclick="FillData(${pageNo})">More...</a></td></tr>`;
                }
                $("#TRMore").remove();
                $("#TBody").append(strHtml);
            });
        }
    </script>
}